/**
* Serializer.java 2020/5/8 7:54 下午
* Copyright ©2020 wondersgroup.com All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package serialization;

import common.model.MagicUrl;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * File：Serializer.java<br>
 * Title: <br>
 * Description: <br>
 * Company: www.treefinance.com.cn <br>
 * @author heyouchi
 */
public interface Serializer {

  /**
   * Get content type unique id, recommended that custom implementations use values greater than 20.
   *
   * @return content type id
   */
  byte getContentTypeId();

  /**
   * Get content type
   *
   * @return content type
   */
  String getContentType();

  /**
   * Get a serialization implementation instance
   *
   * @param url URL address for the remote service
   * @param output the underlying output stream
   * @return serializer
   * @throws IOException
   */
  ObjectOutput serialize(MagicUrl url, OutputStream output) throws IOException;

  /**
   * Get a deserialization implementation instance
   *
   * @param url URL address for the remote service
   * @param input the underlying input stream
   * @return deserializer
   * @throws IOException
   */
  ObjectInput deserialize(MagicUrl url, InputStream input) throws IOException;
}
